package com.geeksaga.dao.ibatis.oracle;

import java.util.List;


import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.geeksaga.dao.BbsStarDao;
import com.geeksaga.dao.ibatis.BaseIBatisDao;
import com.geeksaga.domain.BbsStar;

/**
 * @author newbie
 * @since 0.1
 */
@Repository
public class BbsStarDaoImpl extends BaseIBatisDao implements BbsStarDao {

    /* (non-Javadoc)
     * @see com.geeksaga.dao.BbsStarDao#add(com.geeksaga.domain.BbsStar)
     */
    public BbsStar add(BbsStar bbsStar) throws DataAccessException {
        return (BbsStar) getSqlMapClientTemplate().insert("BBS_STAR.add", bbsStar);
    }

    /* (non-Javadoc)
     * @see com.geeksaga.dao.BbsStarDao#exists(com.geeksaga.domain.BbsStar)
     */
    @SuppressWarnings("unchecked")
    public boolean exists(BbsStar bbsStar) throws DataAccessException {
        List<BbsStar> list = (List<BbsStar>) getSqlMapClientTemplate().queryForList("BBS_STAR.find", bbsStar);
        
        if(list == null || (list != null && list.size() == 0))
            return false;
        else
            return true;
    }

    /* (non-Javadoc)
     * @see com.geeksaga.dao.BbsStarDao#calculate(com.geeksaga.domain.BbsStar)
     */
    public BbsStar calculate(BbsStar bbsStar) throws DataAccessException {
        return (BbsStar) getSqlMapClientTemplate().queryForObject("BBS_STAR.calculate", bbsStar);
    }
}